/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * cambiar_matricula.java
 *
 * Created on 24-oct-2011, 3:08:59
 */

package proyectocatalina.matricula;

import CapadeDatos.daolistadoalumnos2;
import javax.swing.JOptionPane;
import modelo.beanalumno;

/**
 *
 * @author Vilma
 */
public class cambiar_matricula extends javax.swing.JInternalFrame {

    /** Creates new form cambiar_matricula */
    public cambiar_matricula() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jtxtcodmat = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jbtnbuscarmat = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jtxtnombre = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jtxtapemat = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jtxtapepat = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jtxtestado = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jbtnchangeestadomat = new javax.swing.JButton();
        jtxtcarrera = new javax.swing.JTextField();
        jtxtdni = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();

        setClosable(true);
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("Modificar Matricula");

        jtxtcodmat.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jtxtcodmatFocusGained(evt);
            }
        });

        jLabel1.setText("Codigo de Matricula");

        jbtnbuscarmat.setText("Buscar");
        jbtnbuscarmat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnbuscarmatActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Modificar Matricula"));

        jLabel5.setText("Carrera :");

        jtxtnombre.setEnabled(false);

        jLabel4.setText("Nombres :");

        jtxtapemat.setEnabled(false);
        jtxtapemat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtapematActionPerformed(evt);
            }
        });

        jLabel2.setText("Apellidos :");

        jtxtapepat.setEnabled(false);

        jLabel7.setText("ACTIVAR/INACTIVAR");

        jtxtestado.setEnabled(false);

        jLabel3.setText("ESTADO :");

        jbtnchangeestadomat.setText("Cambiar Estado");
        jbtnchangeestadomat.setEnabled(false);
        jbtnchangeestadomat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnchangeestadomatActionPerformed(evt);
            }
        });

        jtxtcarrera.setEnabled(false);
        jtxtcarrera.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtcarreraActionPerformed(evt);
            }
        });

        jtxtdni.setEnabled(false);
        jtxtdni.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtdniActionPerformed(evt);
            }
        });

        jLabel6.setText("DNI :");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel4)
                    .addComponent(jLabel6)
                    .addComponent(jLabel5)
                    .addComponent(jLabel3))
                .addGap(51, 51, 51)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jtxtapepat, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxtapemat, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jtxtnombre, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE)
                    .addComponent(jtxtcarrera, javax.swing.GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE)
                    .addComponent(jtxtdni, javax.swing.GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel7)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jtxtestado, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE)
                                .addComponent(jbtnchangeestadomat)))
                        .addGap(19, 19, 19)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtapepat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(jtxtapemat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtnombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtcarrera, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jtxtdni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtestado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(jbtnchangeestadomat))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 14, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jtxtcodmat)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbtnbuscarmat))
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtxtcodmat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtnbuscarmat))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(27, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jtxtapematActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtapematActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtxtapematActionPerformed

    private void jtxtcarreraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtcarreraActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtxtcarreraActionPerformed

    private void jtxtdniActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtdniActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtxtdniActionPerformed

    private void jbtnbuscarmatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnbuscarmatActionPerformed
String codmat;
        beanalumno alumno;
        codmat=jtxtcodmat.getText();
     alumno=(beanalumno)daolistadoalumnos2.matriculado(codmat);

     jtxtapepat.setText(alumno.getApepat());
     jtxtapemat.setText(alumno.getApemat());
     jtxtnombre.setText(alumno.getNombre());
     jtxtcarrera.setText(alumno.getCarrera());
     jtxtdni.setText(alumno.getDni());
     jtxtestado.setText(alumno.getEstado());


    jbtnchangeestadomat.setEnabled(true);
        // TODO add your handling code here:
    }//GEN-LAST:event_jbtnbuscarmatActionPerformed

    private void jbtnchangeestadomatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnchangeestadomatActionPerformed
String cod_mat;
String estado=jtxtestado.getText();
cod_mat=jtxtcodmat.getText();
int r;
r=JOptionPane.showConfirmDialog(null,"CONFIRMAR","Esta seguro"
        + " que desea Cambiar el estado de la matricula"
        +cod_mat ,JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE);

if (r==0)
{

    daolistadoalumnos2 h =new daolistadoalumnos2();

        h.cambiarestadomatricula(cod_mat,estado);

String codmat;
        beanalumno alumno;
        codmat=jtxtcodmat.getText();
     alumno=(beanalumno)daolistadoalumnos2.matriculado(codmat);
jtxtestado.setText(alumno.getEstado());
        }


        // TODO add your handling code here:
    }//GEN-LAST:event_jbtnchangeestadomatActionPerformed

    private void jtxtcodmatFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtxtcodmatFocusGained
jbtnchangeestadomat.setEnabled(false);
        // TODO add your handling code here:
    }//GEN-LAST:event_jtxtcodmatFocusGained

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new cambiar_matricula().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JButton jbtnbuscarmat;
    private javax.swing.JButton jbtnchangeestadomat;
    private javax.swing.JTextField jtxtapemat;
    private javax.swing.JTextField jtxtapepat;
    private javax.swing.JTextField jtxtcarrera;
    private javax.swing.JTextField jtxtcodmat;
    private javax.swing.JTextField jtxtdni;
    private javax.swing.JTextField jtxtestado;
    private javax.swing.JTextField jtxtnombre;
    // End of variables declaration//GEN-END:variables

}
